home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / C / Comet2.1.3.cpt / 3270XCMD / TNStatus.c < prev    next >
Text File  |  1990-03-21  |  2KB  |  118 lines

  1. /* TNStatus.c -- XCMD to get TN3270 connection status
  2.     copyright 1989 Cornell University 
  3. */
  4.  
  5.  
  6. #include <Types.h>
  7. #include <Memory.h>
  8. #include <Devices.h>
  9. #include <HyperXCmd.h>
  10. #include <Errors.h>
  11.  
  12. #include <String.h>
  13.  
  14. #include "TNdrvr.h"
  15.  
  16.  
  17. pascal void debugger()    extern 0xA9FF;   
  18.  
  19.  
  20. pascal void TNStatus(hycp)
  21. XCmdPtr hycp;
  22. {
  23.     CntrlParam drvpb;
  24.     Str255 pstr;
  25.     
  26.     if (hycp->paramCount != 1) {
  27.         sethand(&hycp->returnValue, 
  28.             "TNStatus TNID: need 1 argument");
  29.         return;
  30.     }
  31.  
  32.     HLock((Handle) hycp->params[0]);
  33.     
  34.     ZeroToPas(hycp, *hycp->params[0], (StringPtr) &pstr[0]);
  35.     drvpb.ioCRefNum = (short) StrToNum(hycp, (Str31 *) &pstr[0]);
  36.     drvpb.csCode = HTN_STATUS;
  37.     PBControl((ParmBlkPtr) &drvpb, (Boolean) 0);
  38.  
  39.     if (drvpb.ioResult) {
  40.         /* maybe an error, maybe a status result */
  41.         switch (drvpb.ioResult) {
  42.             case HTNR_NOTN: {
  43.                 sethand(&hycp->returnValue, "TN is not running");
  44.                 break;
  45.             }
  46.             case HTNR_ACTIVE: {
  47.                 sethand(&hycp->returnValue, "TN not opened");
  48.                 break;
  49.             }
  50.             case HTNR_OPEN: {
  51.                 sethand(&hycp->returnValue, "TN has no connection");
  52.                 break;
  53.             }
  54.             case HTNS_RUNNING: {
  55.                 sethand(&hycp->returnValue, "");
  56.                 break;
  57.             }
  58.             case HTNS_WAITCONN: {
  59.                 sethand(&hycp->returnValue, "TN waiting for connection");
  60.                 break;
  61.             }
  62.             case HTNS_WAITNET: {
  63.                 sethand(&hycp->returnValue, "TN waiting on network");
  64.                 break;
  65.             }
  66.             case HTNS_NEWDATA: {
  67.                 sethand(&hycp->returnValue, "New Data");
  68.                 break;
  69.             }
  70.             case HTNS_KBDLOCK: {
  71.                 sethand(&hycp->returnValue, "Keyboard locked");
  72.                 break;
  73.             }
  74.             case HTNS_MORE: {
  75.                 sethand(&hycp->returnValue, "More...");
  76.                 break;
  77.             }
  78.             case HTNS_HOLDING: {
  79.                 sethand(&hycp->returnValue, "HOLDING");
  80.                 break;
  81.             }
  82.             case HTNS_CP: {
  83.                 sethand(&hycp->returnValue, "CP");
  84.                 break;
  85.             }
  86.             case HTNS_VMREAD: {
  87.                 sethand(&hycp->returnValue, "VM READ");
  88.                 break;
  89.             }
  90.             case badUnitErr: {
  91.                 sethand(&hycp->returnValue, "TNID is incorrect");
  92.                 break;
  93.             }
  94.             default: {
  95.                 sethand(&hycp->returnValue, "Unknown error");
  96.                 break;
  97.             }
  98.         }
  99.     }
  100.     HUnlock((Handle) hycp->params[0]);
  101. }
  102.  
  103.  
  104. sethand(thand, str)
  105. Handle * thand;
  106. char * str;
  107. {
  108.     if (*thand == NULL) {
  109.         *thand = NewHandle((Size) 0);
  110.     }
  111.     SetHandleSize(*thand, (long) (strlen(str) + 1));
  112.     strcpy(**thand, str);
  113. }
  114.  
  115.  
  116.  
  117.  
  118. #include <XCmdGlue.inc.c>